import { Cache } from "../../cache/Cache";
import { TToplist } from "../../../../Message/Db/Tables/TToplist";
import { SEntityId } from "../../../../Message/Public/SEntityId";
import { SPublicMiniPlayer } from "../../../../Message/Public/SPublicMiniPlayer";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { PlayerMiniInfo } from "../../model/PlayerMiniInfo";
import { PlayerOpRegister } from "../common/menu/PlayerOpRegister";
type int = number;
//class RankBaseItem
    
    export  class RankBaseItem /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._serverId = Cache.instance.ranking.serverId;
            return;
        }

        public get rank(): int
        {
            return this._data.rank;
        }

        public get data(): TToplist
        {
            return this._data;
        }

        public get isDraw(): Boolean
        {
            return this._isDraw;
        }

        public get playerId(): int
        {
            if (this._data != null) 
            {
                return this._data.entityId;
            }
            return 0;
        }

        public get sEntityId(): SEntityId
        {
            return this._sEntityId;
        }

        public drawGrayColor(): void
        {
            var loc1=null;
            var loc2=null;
            this._isDraw = true;
            if (this._bgBitmap == null) 
            {
                this._bgBitmap = new Object /* flash.display.Bitmap */();
                loc1 = new Object /* flash.display.Shape */();
                loc1.graphics.beginFill(11661311, 0.2);
                loc1.graphics.lineStyle(1, 11661311, 0);
                loc1.graphics.drawRoundRect(0, 0, 460, 30, 5, 5);
                loc1.cacheAsBitmap = true;
                loc2 = new Object /* flash.display.BitmapData */(460, 30, true, 0);
                loc2.draw(loc1);
                this._bgBitmap.bitmapData = loc2;
                this._bgBitmap.y = -5;
            }
            addChildAt(this._bgBitmap, 0);
            return;
        }

        public clearBgColor(): void
        {
            this._isDraw = false;
            if (this._bgBitmap && this._bgBitmap.parent) 
            {
                removeChild(this._bgBitmap);
            }
            return;
        }

        protected initPlayerMenuInfo(): void
        {
            this._serverId = Cache.instance.ranking.serverId;
            this._sEntityId = new SEntityId();
            this._sEntityId.id = this._data.entityId;
            this._sEntityId.type = 1;
            this._sEntityId.typeEx = this._serverId;
            this._sEntityId.typeEx2 = Cache.instance.role.entityInfo.entityId.typeEx2;
            this._sMiniPlayer = new SPublicMiniPlayer();
            this._sMiniPlayer.camp = this._data.propertyOne;
            this._sMiniPlayer.sex = this._data.propertyTwo;
            this._sMiniPlayer.career = this._data.propertyThree;
            this._sMiniPlayer.name = this._data.entityName;
            this._sMiniPlayer.level = this._data.valueOne;
            this._sMiniPlayer.entityId = this._sEntityId;
            return;
        }

        public onItemLookupPlayerClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (!(this._sEntityId == null) && !this._isDraw) 
            {
                this.drawGrayColor();
                Dispatcher.dispatchEvent(new DataEvent(EventName.LookUpTargetEquip, this._sEntityId));
                this._x = arg1.stageX;
                this._y = arg1.stageY;
            }
            return;
        }

        public registerPlayerMenu(arg1: int): void
        {
            if (this._isDraw) 
            {
                this._sMiniPlayer.online = arg1;
                this._playerMiniInfo = null;
                this._playerMiniInfo = new PlayerMiniInfo(this._sMiniPlayer);
            }
            return;
        }

        public onItemDoubleClickShowPlayerMenu(): void
        {
            if (!(this._sMiniPlayer == null) && this._sMiniPlayer.online == 1) 
            {
                PlayerOpRegister.ShowOpList(this._playerMiniInfo, this._x, this._y);
            }
            return;
        }

        protected /* var */_data: TToplist;

        protected /* var */_serverId: int;

        protected /* var */_isDraw: Boolean=false;

        protected /* var */_sMiniPlayer: SPublicMiniPlayer;

        protected /* var */_playerMiniInfo: PlayerMiniInfo;

        protected /* var */_sEntityId: SEntityId;

        protected /* var */_bgBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_x: number=600;

        /* internal */ /* var */_y: number=135;
    }
